package com.uusee.shipshape.zq.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.uusee.shipshape.gt.model.SourceSite;

@Entity
@Table(name = "ss_zq_video_query_rule")
@SuppressWarnings("serial")
public class VideoQueryRule {
	@Id
	@Column(name = "code")
	private String code;

	private String name;

	@Column(name = "query_rule")
	private String queryRule;

	@Column(name = "key_encoder")
	private String keyEncoder;

	@Column(name = "page_size")
	private int pageSize;

	@ManyToOne
	@JoinColumn(name = "video_reg_id")
	private VideoReg videoReg;
	
	@ManyToOne
	@JoinColumn(name = "source_site")
	private SourceSite sourceSite;

	@Column(name = "update_user")
	private String updateUser;

	@Column(name = "update_date")
	private Date updateDate;
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getQueryRule() {
		return queryRule;
	}

	public void setQueryRule(String queryRule) {
		this.queryRule = queryRule;
	}

	public String getKeyEncoder() {
		return keyEncoder;
	}

	public void setKeyEncoder(String keyEncoder) {
		this.keyEncoder = keyEncoder;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public VideoReg getVideoReg() {
		return videoReg;
	}

	public void setVideoReg(VideoReg videoReg) {
		this.videoReg = videoReg;
	}
	
	public SourceSite getSourceSite() {
		return sourceSite;
	}

	public void setSourceSite(SourceSite sourceSite) {
		this.sourceSite = sourceSite;
	}

	public String getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(String updateUser) {
		this.updateUser = updateUser;
	}

	public Date getUpdateDate() {
		return updateDate;
	}

	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}

	public static VideoQueryRule getYoukuCategoryVideoQueryRule() { 
		SourceSite youku = new SourceSite();
		youku.setSiteCode("youku");
		
		VideoQueryRule qr = new VideoQueryRule();
		qr.name = "youku";
		qr.queryRule = "http://www.youku.com/v_showlist/t1c0d1p::PAGE.html";
		qr.keyEncoder = "UTF-8";
		qr.videoReg = VideoReg.getYoukuCategoryVideoReg(youku);
		return qr;
	}
	
	public static VideoQueryRule getYoukuVideoQueryRule() { 
		SourceSite youku = new SourceSite();
		youku.setSiteCode("youku");
		
		VideoQueryRule qr = new VideoQueryRule();
		qr.name = "youku";
		qr.queryRule = "http://so.youku.com/search_video/q_::KEY_orderby_1_page_::PAGE.html";
		qr.keyEncoder = "UTF-8";
		qr.videoReg = VideoReg.getYoukuQueryPageVideoReg(youku);
		return qr;
	}
	
	public static VideoQueryRule getKuliuVideoQueryRule() { 
		SourceSite ku6 = new SourceSite();
		ku6.setSiteCode("ku6");
		
		VideoQueryRule qr = new VideoQueryRule();
		qr.setName("kuliu");
		qr.setQueryRule("http://so.ku6.com/v?q=::KEY&p=::PAGE");
		qr.setKeyEncoder("UTF-8");
		qr.setVideoReg(VideoReg.getKuliuQueryPageVideoReg(ku6));
		return qr;
	}
	
	public static VideoQueryRule getTudouVideoQueryRule() { 
		SourceSite tudou = new SourceSite();
		tudou.setSiteCode("tudou");
		
		VideoQueryRule qr = new VideoQueryRule();
		qr.setName("tudou");
		qr.setQueryRule("http://so.tudou.com/isearch.do?kw=::KEY&cid=&time=0&sort=&high=0&display=table&page=::PAGE");
		qr.setKeyEncoder("GBK");
		qr.setVideoReg(VideoReg.getTudouQueryPageVideoReg(tudou));
		return qr;
	}
	
	public static VideoQueryRule getSinaVideoQueryRule() { 
		SourceSite sina = new SourceSite();
		sina.setSiteCode("sina");
		
		VideoQueryRule qr = new VideoQueryRule();
		qr.setName("sina");
		qr.setQueryRule("http://search.you.video.sina.com.cn/s?key=::KEY&type=video&page=::PAGE&sort=click");
		qr.setKeyEncoder("gb2312");
		qr.setVideoReg(VideoReg.getSinaQueryPageVideoReg(sina));
		return qr;
	}
	
	public static VideoQueryRule getWuliuVideoQueryRule() { 
		SourceSite wuliu = new SourceSite();
		wuliu.setSiteCode("56");
		
		VideoQueryRule qr = new VideoQueryRule();
		qr.setName("56");
		qr.setQueryRule("http://so.56.com/index?type=video&sortby=3&key=::KEY&&startat=::START");
		qr.setKeyEncoder("gb2312");
		qr.setPageSize(8);
		qr.setVideoReg(VideoReg.getWuliuQueryPageVideoReg(wuliu));
		return qr;
	}
	
	public static VideoQueryRule getSohuVideoQueryRule() { 
		SourceSite wuliu = new SourceSite();
		wuliu.setSiteCode("56");
		
		VideoQueryRule qr = new VideoQueryRule();
		qr.setName("56");
		qr.setQueryRule("http://so.56.com/index?type=video&sortby=3&key=::KEY&&startat=::START");
		qr.setKeyEncoder("gb2312");
		qr.setPageSize(8);
		qr.setVideoReg(VideoReg.getWuliuQueryPageVideoReg(wuliu));
		return qr;
	}

}
